import pickle
my_dict = {'name':'xuebi','age':24}
path = './file/text.txt'
with open('./file/text.txt','wb') as f:  # wb表示以二进制写入
    pickle.dump(my_dict,f)